package com.example.springbook.enums;

public enum BookStatus {
    DELETED(0,"无效"),
    NORMAL(1,"可借阅"),
    FORBIDDEN(2,"不可借阅");
    private int code;
    private String name;



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    BookStatus(int code, String name) {
        this.code = code;
        this.name = name;
    }
    public static BookStatus getNameByCode(Integer code){
        switch (code){
            case 0: return DELETED;
            case 1: return NORMAL;
            case 2: return FORBIDDEN;
        }
        return null;
    }
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }








    public static BookStatus getDescByCode(int code){
        switch (code){
            case 0: return BookStatus.DELETED;
            case 1: return BookStatus.NORMAL;
            case 2: return BookStatus.FORBIDDEN;
        }
        return BookStatus.DELETED;
    }
}
